<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con">
            <span>编辑投标信息池</span><div class="move_title"></div><?php include "../public/sub.php";?></div>
    </div>
    <div class="main-container">
        <div class="block-generic">

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" id="number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目类型</label>
                        <div class="layui-input-block">
                            <div id="bidtype"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目所在地</label>
                        <div class="layui-input-block" style="z-index: 1;">
                            <input type="text" name="areas" id="areas" placeholder="请选择" readonly clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="addr" id="addr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhaoname" id="zhaoname" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhaotel" id="zhaotel" placeholder="请输入"  clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">预计合同金额(万元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="yufee" name="yufee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput6">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方式</label>
                        <div class="layui-input-block">
                            <div id="zhaotype"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目所属单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=chanid&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="chanid"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=chanid&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="chanid_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目属性</label>
                        <div class="layui-input-block ">
                            <select id="business" name="business" lay-filter="business">
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">经营备案人</label>
                        <div class="layui-input-block">
                            <input type="text" name="jingbeier" id="jingbeier" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">信息来源</label>
                        <div class="layui-input-block">
                            <input type="text" name="xinlai" id="xinlai" placeholder="请输入"  clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">项目概况</label>
                        <div class="layui-input-block">
                            <textarea id="gai" name="gai" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>

            <?php include '../public/upinfo.php'?>
        </div>


    </div>
</form>
<script>
    var param_id = getQueryVariable('id');

    $("#commentForm").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form;
        render_input_attr();


        facade.ajax({type: 'get', url: ask_bid_pool_edit, data:{id: param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $('#name').val(data.name);
                $('#number').val(data.number);
                $('#addr').val(data.addr);
                $('#zhaoname').val(data.zhaoname);
                $('#zhaotel').val(data.zhaotel);
                $('#yufee').val(data.yufee);
                $('#business').val(data.business);
                $('#jingbeier').val(data.jingbeier);
                $('#xinlai').val(data.xinlai);
                $('#gai').val(data.gai);
                $('#explain').val(data.explain);

                if(data.chanid_info.length > 0){
                    tan_tags_init('#chanid', data.chanid_info);
                }

                $("#areas").val(data.areas);
                load_areas('areas', res.data.areas, 3);


                xmselect_dan('bidtype', res.data.bidtype, data.bidtype);
                xmselect_dan('zhaotype', res.data.zhaotype, data.zhaotype);

                public_upload_file_load('upload_files', res.data.files);
                render_date();
                render_from();
                initParseMoney();
            }
        });

        form.on('submit(add)', function(data){
            var validRes = $("#commentForm").valid();

            data.field.chanid = tan_tags_getvalue("#chanid", 'dept');

            if(!data.field.chanid){
                $("#chanid").parents('.tanxian').addClass('tanerror');
                $('#chanid_tanerror').text('请选择');
                validRes = false;
            }else{
                $("#chanid").parents('.tanxian').removeClass('tanerror');
                $('#chanid_tanerror').text('');
            }

            if(!validRes){return false;}



            data.field.files = public_upload_file_value('upload_files');
            data.field.id = param_id;
            data = parseMoney(data);
            facade.ajax({url: ask_bid_pool_edit, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });
</script>
</body>
</html>
